import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { TextRenderer } from "../engine/TextRenderer";
import { Transform } from "../engine/Transform";
import { number } from "../engine/validators/number";
import { Display } from "./Display";
import { ItemSpeed } from "./ItemSpeed";

export class CharacterWalkable extends Behaviour {
    private currentSpeed = 0;
    @number()
    speed = 5;
    ArrivedFlag=0;

    onStart() {
        if(getGameObjectById('Character_1').getBehaviour(ItemSpeed).speed==0){
            this.currentSpeed=this.speed;

        }else{
            this.currentSpeed=0;
        }

        
    }

    onTick(duringTime: number) {
        const transform_characterr_1 = getGameObjectById('Character_1').getBehaviour(Transform);
        if(transform_characterr_1.y>=130){
            transform_characterr_1.y-=this.currentSpeed;
        }else{
            this.currentSpeed=0;
            getGameObjectById('Character_1').getBehaviour(ItemSpeed).speed==0
        }

    }
}
